#include "include.h"

using namespace std;

bool ShowHide = true;

GUI_TextBox* login = new GUI_TextBox(0, 0, 400, 50);
GUI_TextBox* password = new GUI_TextBox(0, 0, 400, 50);
GUI_Button* loginbutton = new GUI_Button("Login", 0, 0, 125, 40);

void onLoginButtonClicked()
{
	if (login->GetText().length() == 0 || password->GetText().length() == 0) return;
}

void onLoginStart()
{
	login->Toggle(true);
	password->Toggle(true);
	login->SetPos(getScreenGameX()/2-200, getScreenGameY()-200);
	password->SetPos(getScreenGameX()/2-200, getScreenGameY()-100);
	login->SetColor(255, 0, 0);
	password->SetColor(255, 0, 0);
	login->SetFont(".\\data\\fonts\\font2.ttf");
	password->SetFont(".\\data\\fonts\\font2.ttf");
	
	password->Masking(true);

	loginbutton->Toggle(true);
	loginbutton->SetPos(getScreenGameX()/2, 300);

	loginbutton->clicked = std::bind (&onLoginButtonClicked);
}

void LoginToggle(bool toggle)
{
	ShowHide = toggle;
	login->Toggle(toggle);
	password->Toggle(toggle);
	loginbutton->Toggle(toggle);
}

void LoginRender()
{
	if (ShowHide == true)
	{
		drawText(0, 200, 200, 50, "Username:", ".\\data\\fonts\\font1.ttf", "center", 32, getScreenGameX()/2, getScreenGameY()-240);
		drawText(0, 200, 200, 50, "Password:", ".\\data\\fonts\\font1.ttf", "center", 32, getScreenGameX()/2, getScreenGameY()-140);
		login->Render();
		password->Render();
		loginbutton->Render();

		if (!password->GetText().length() == 0)
		{
			drawText(0, 200, 200, 50, password->GetText(), ".\\data\\fonts\\font2.ttf", "center", 32, getScreenGameX()/2, 100);
		}
		
	}
}

void LoginEvents(SDL_Event& events)
{
	login->Events(events);
	password->Events(events);
	loginbutton->Events(events);
}